package cn.edu.ujn.lab3.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.ujn.lab3.dao.UserMapper;
import cn.edu.ujn.lab3.dao.User;
import cn.edu.ujn.lab3.service.IUserService;
/**
 * 用户Service接口实现类
 */
@Service("userService")
@Transactional
public class UserServiceImpl implements IUserService {
	// 注入UserDao
	@Autowired
	private UserMapper userDao;
	// 通过账号和密码查询用户
	@Override
	@Transactional
	public User findUser(String usercode, String password) {
		User user = this.userDao.findUser(usercode, password);
		return user;
	}
	//注册用户
	@Override
	@Transactional
	public int register(User user) {
		
		return userDao.insert(user);
	}  
	//通过用户账号查询用户
	@Override
	@Transactional
	public User selectByCode(String UserCode) {
		// TODO Auto-generated method stub
		return userDao.selectByCode(UserCode);
	}
}